<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<f:facet name="first">
		<title>#{msgs.v2trainer}</title>
	</f:facet>

	<meta http-equiv="X-UA-Compatible" content="EmulateIE8" />
	<meta content='text/html; charset=ISO-8859-1' http-equiv="Content-Type" />
	<link type="text/css" href="#{request.contextPath}/css/default.css"	rel="stylesheet" />
    <script type="text/javascript" src="#{request.contextPath}/css/script/script.js"/>
	<ui:insert name='script'/>
</h:head>

<f:event type="preRenderView" listener="#{userBean.loadHolders}"   />


<h:body>
	
	<p:growl id="growl" showDetail="true" life="6000" widgetVar="wgrowl" autoUpdate="true" />

	<ui:insert name="dialogs"/>

	<p:layout id="layout" fullPage="true" widgetVar="wlayout" >

		<p:layoutUnit  position="north" resizable="true" closable="true" collapsible="true"  style="border:0px;margin:0px;padding:0px;border:none" > 
			<div id="header"  class=" ui-widget " style="border:0px;margin:0px;padding:0px;background:white" >
				<h:panelGrid columns="2"  width="100%" columnClasses=",bottom-right" >
					<p:column>
						<h:panelGrid columns="2" cellpadding="2"  >
							<p:column>
								<p:graphicImage  url="/images/default_logo_wide.jpg" width="250"  height="80" rendered="#{userBean.agreementHolder == null}" />
								<p:graphicImage  url="#{userBean.agreementHolder.wideLogo.folder}#{userBean.agreementHolder.wideLogo.location}" width="250"  height="80" rendered="#{userBean.agreementHolder != null}" />
							</p:column>
							<p:column  >
								<div align="left" style="heigh:100%">
									<p:spacer height="50"/>
									<br/>
									<p:spacer width="20"/>
									<p:outputLabel value="Bem-vindo, #{loginBean.greetings} " style="font-size:22px;font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif;"></p:outputLabel>
								</div>
							</p:column>
						</h:panelGrid>				
					</p:column>
					<p:column>
						<div>
							<p:outputPanel layout="block" style="vertical-align:middle"   rendered="#{p:ifAnyGranted('ROLE_ATHLETE')}" >
								<h:form>
									<p:outputLabel value="#{userBean.agreementHolder.name} " style="vertical-align:middle"   />
	
									
									<p:outputLabel value="#{msgs.Contracts}: " style="vertical-align:middle"   />
									<p:selectOneMenu value="#{userBean.agreementHolder}"  converter="#{genericConverter}" style="width:200px;vertical-align:middle">							
										<f:selectItems value="#{userBean.agreementHolders}"	var="agreementHolder" itemLabel="#{agreementHolder.name}" itemValue="#{agreementHolder}"/>
									</p:selectOneMenu>
									<p:button  value="#{msgs.Go}" outcome="/welcome.jsf"    />
									<p:commandButton value="#{msgs.Contract}..."  />
								</h:form>
							</p:outputPanel>	
						</div>
					</p:column>
				</h:panelGrid>

				<h:form>
					<script type="text/javascript">
						$( document ).ready(function() {
							menuHighLight();
						});
						
						function menuHighLight() {
							var $menuButtons = $(".ui-menubar .ui-menuitem "); 	
							$menuButtons.each(function(index, menuButton) {
								var link = $(menuButton).find(".ui-menuitem-link").attr("href");
								if(document.location.href.indexOf(link) > -1){
									$(menuButton).find(".ui-menuitem-link").addClass("ui-state-highlight");
								}else{
									$(menuButton).find(".ui-menuitem-link").removeClass("ui-state-highlight");
								}
							});
						};
					</script>
					<p:menubar id="menuTop" style="padding:0px;" styleClass="ui-widget-header" >
						<p:menuitem value="#{msgs.MyData}" 		url="/admin/admins.jsf" 						rendered="#{p:ifGranted('ROLE_ADMIN')}" />
						<p:menuitem value="#{msgs.MyData}"		url="/athlete/athletes.jsf" 					rendered="#{p:ifGranted('ROLE_ATHLETE')}"/>
						<p:menuitem value="#{msgs.MyData}" 		url="/academy/academys.jsf" 					rendered="#{p:ifGranted('ROLE_ACADEMY')}" />
						<p:menuitem value="#{msgs.MyData}"		url="/teacher/teachers.jsf"						rendered="#{p:ifGranted('ROLE_TEACHER')}"/>
						<p:menuitem value="#{msgs.MyData}" 		url="/personalTrainer/personalTrainers.jsf" 	rendered="#{p:ifGranted('ROLE_PERSONAL')}" />

						<p:submenu label="#{msgs.Users}" 		rendered="#{p:ifAnyGranted('ROLE_ADMIN, ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}"  >
							<p:menuitem value="#{msgs.Athletes}"		 	url="/athlete/athletes.jsf" 					rendered="#{p:ifAnyGranted('ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}"	/>
							<p:menuitem value="#{msgs.Academys}" 		 	url="/academy/academys.jsf" 					rendered="#{p:ifGranted('ROLE_ADMIN')}" />
							<p:menuitem value="#{msgs.Teachers}"		 	url="/teacher/teachers.jsf"						rendered="#{p:ifGranted('ROLE_ACADEMY')}"/>
							<p:menuitem value="#{msgs.PersonalTrainers}" 	url="/personalTrainer/personalTrainers.jsf" 	rendered="#{p:ifGranted('ROLE_ADMIN')}" />
						</p:submenu>
						<p:menuitem value="#{msgs.Modalitys}" 			url="/modality/modalitys.jsf"				rendered="#{p:ifAnyGranted('ROLE_ADMIN, ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}"/>
						<p:submenu label="#{msgs.Schedules}">
							<p:menuitem value="#{msgs.Schedules}" 		url="/schedule/schedules.jsf" 	/>
							<p:menuitem value="#{msgs.Cycles}" 			url="/schedule/schedule.jsf" 	/>
						</p:submenu>
						<p:menuitem value="#{msgs.TrainingSystems}" 	url="/trainingSystem/trainingSystems.jsf"	rendered="#{p:ifAnyGranted('ROLE_ADMIN, ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}"/>
						<p:menuitem value="#{msgs.ExercisesGroup}" 		url="/exerciseGroup/exerciseGroups.jsf"		rendered="#{p:ifAnyGranted('ROLE_ADMIN, ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}"/>
						<p:menuitem value="#{msgs.Training}" 			url="/training/trainings.jsf"				rendered="#{p:ifAnyGranted('ROLE_ADMIN, ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}" />	
						<p:menuitem value="#{msgs.Equipments}" 			url="/equipment/equipments.jsf"				rendered="#{p:ifAnyGranted('ROLE_ADMIN, ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}" />
						<p:menuitem value="#{msgs.Librarys}" 			url="/library/librarys.jsf"					/>
				
						<p:menuitem value="#{msgs.Exit}"  				url="/j_spring_security_logout"/>
						
						<f:facet name="options">  
							<p:commandButton type="button" icon="ui-icon-triangle-1-n"  onclick="wlayout.layout.close('north')" style="padding:0px;margin:0px" />
						</f:facet>
					</p:menubar>
				</h:form>
			</div>
		</p:layoutUnit> 

		<p:layoutUnit id="options" header="#{msgs.Options}" position="west" resizable="false" size="225" maxSize="225" collapsible="true" collapsed="true" >
			<ui:insert name="menu"/>
		</p:layoutUnit>
		
		<p:layoutUnit position="center" > 
			<ui:insert name="center"/>
		</p:layoutUnit>  

		<p:layoutUnit id="tools" header="#{msgs.Tools}" position="south" resizable="true" size="400"  collapsible="true" collapsed="true">
			<ui:insert name="tools"/>
		</p:layoutUnit>
	</p:layout>

<!-- 	<h:form id="keepAliveForm" prependId="false"> -->
<!-- 		<p:poll id="keepAlive" update="@this" autoStart="true" interval="60"   /> -->
<!-- 	</h:form> -->

</h:body>
</html>